#include "precompile.h"

#include "LoadingThread.h"
#include "LoadingManager.h"
#include "sys/concurrent/Mutex.h"

LoadingThread::LoadingThread(LoadingManager* manager,const String& category)
	:m_manager(manager),
	m_category(category)
{
}

LoadingThread::~LoadingThread()
{}

void LoadingThread::Run()
{
	concurrent::Mutex lock;
	lock.Lock();

	LoadCategory();
}

void LoadingThread::LoadCategory()
{
	if (m_manager)
	{
		StringArray arrComponents;
		m_manager->GetComponentListInCategory(m_category, arrComponents);
		for (unsigned i = 0; i < arrComponents.size(); i++)
		{
			m_manager->LoadComponentDirectly(arrComponents[i].c_str());
		}

		m_manager->NotifyLoaderThreadFinished(m_category);
	}
}